package com.wswy.wzcx.ui.main.community.add

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MutableLiveData
import com.wswy.wzcx.AppContext
import com.wswy.wzcx.model.topic.TopicTagType
import com.wswy.wzcx.module.TopicTagsLoader
import com.wswy.wzcx.module.base.UserViewModel

class AddTopicViewModel : UserViewModel() {

    private val tagsLoader = TopicTagsLoader(AppContext.getContext())


    private val tagsConfLiveData = MutableLiveData<List<TopicTagType>?>()

    override fun onCreate() {
        super.onCreate()
        registerObservers()
    }


    fun loadTags(){

        tagsLoader.loader {

            it.orNull()?.run {
                tagsConfLiveData.postValue(this)
            }?:kotlin.run {
                tagsConfLiveData.postValue(null)
            }

        }

    }

    fun getTagsConfLiveData():LiveData<List<TopicTagType>?> = tagsConfLiveData


}